//
//  PCDetailsViewController.m
//  wedding
//
//  Created by 常宽 on 15/1/19.
//  Copyright (c) 2015年 常宽. All rights reserved.
//

#import "PCDetailsViewController.h"
#import "PreparationsModel.h"
#import "StrategyView.h"            /// 攻略页的自定义View
#import "StrategyModel.h"           /// 攻略页的自定义model
#import "StrategyViewController.h"  /// 攻略页的下级视图控制器

#import "ProcurementView.h"         /// 采购页的自定义View
#import "ItemModel.h"               /// 采购页受宠单品model
#import "ProItemViewController.h"   ///      受宠单品下级视图控制器
#import "GoodsModel.h"              /// 采购页推荐商品model
#import "ProGoodsViewController.h"  ///      推荐商品下级视图控制器
#import "GoodsMoreViewController.h" /// 下页,更多商品推荐页
#import "ThemeModel.h"              /// 采购页主题model
#import "ProThemeViewController.h"  ///      主题下级视图控制器
#import "ThemeMoreViewController.h" /// 下页,更多主题页

#import "FinancialView.h"           /// 理财页的自定义View
#import "CalendarView.h"            /// 日历页的自定义View
#import "CollectionView.h"          /// 收藏页的自定义View
#import "BrideSaidView.h"           /// 说说页的自定义View

#define WIDTH self.view.frame.size.width
#define HEIGHT self.view.frame.size.height

@interface PCDetailsViewController ()

@end

@implementation PCDetailsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.title = self.model.title;
    
    // 二级页面隐藏tabBar
    self.tabBarController.tabBar.hidden = YES;
    // 重写返回上级页面方法
    UIImage *backImage = [[UIImage imageNamed:@"返回.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    self.navigationItem.leftBarButtonItem= [[UIBarButtonItem alloc] initWithImage:backImage style:UIBarButtonItemStylePlain target:self action:@selector(popBack:)];
    [self loadPreparationsView];
}
// 返回上级页面
- (void)popBack:(UIBarButtonItem *)sender
{
    [self.tabBarController.tabBar setHidden:NO];
    [self.navigationController popViewControllerAnimated:YES];
}
/// 加载各种视图
- (void)loadPreparationsView
{
    switch ([self.model.typeId intValue]) {
        case 1080:///  采购
        {
            ProcurementView *view = [[ProcurementView alloc] initWithFrame:self.view.bounds];
            view.itemBlock = ^(ItemModel *model){///受宠单品跳转处
                ProItemViewController *VController = [[ProItemViewController alloc] init];
                VController.model = model;
                [self.navigationController pushViewController:VController animated:YES];
            };
            view.goodsBlock = ^(GoodsModel *model){///推荐商品跳转处
                ProGoodsViewController *goodsController = [[ProGoodsViewController alloc] init];
                goodsController.model = model;
                [self.navigationController pushViewController:goodsController animated:YES];
            };
            view.themeBlock = ^(ThemeModel *model){///主题跳转处
                ProThemeViewController *themeController = [[ProThemeViewController alloc] init];
                themeController.model = model;
                [self.navigationController pushViewController:themeController animated:YES];
            };
            view.themeMoreBlock = ^(void){ /// 更多主题跳转处
                ThemeMoreViewController *more = [[ThemeMoreViewController alloc] init];
                [self.navigationController pushViewController:more animated:YES];
            };
            view.goodsMoreBlock = ^(void){  /// 更多商品推荐跳转处
                GoodsMoreViewController *more = [[GoodsMoreViewController alloc] init];
                [self.navigationController pushViewController:more animated:YES];
            };
            [self.view addSubview:view];
        }
            break;
        case 1081:///  理财
        {
            FinancialView *view = [[FinancialView alloc] initWithFrame:self.view.bounds];
            view.backgroundColor = [WebColor forestGreen];
            [self.view addSubview:view];
        }
            break;
        case 1082:///  日历
        {
            CalendarView *view = [[CalendarView alloc] initWithFrame:self.view.bounds];
            view.backgroundColor = [WebColor gold];
            [self.view addSubview:view];
        }
            break;
        case 1083:///  收藏
        {
            CollectionView *view = [[CollectionView alloc] initWithFrame:self.view.bounds];
            view.backgroundColor = [WebColor khaki];
            [self.view addSubview:view];
        }
            break;
        case 1084:///  故事
        {
            BrideSaidView *view = [[BrideSaidView alloc] initWithFrame:self.view.bounds];
            view.backgroundColor = [WebColor khaki];
            [self.view addSubview:view];
        }
            break;
        case 1085:///  攻略
        {
            StrategyView *view = [[StrategyView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT - 64)];
            [self.view addSubview:view];
            view.tiaozhuanBlock = ^(StrategyModel *model){
                StrategyViewController *VController = [[StrategyViewController alloc] init];
                VController.oldModel = model;
                [self.navigationController pushViewController:VController animated:YES];
            };
        }
            break;
        default:
            break;
    }
}










- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
